
#include "xdns-query.h"

using namespace std;

XdnsQuery::XdnsQuery(XdnsQueryType type,
                     XdnsListener* listener)
: m_type(type),
  m_listener(listener)
{
}

XdnsQuery::~XdnsQuery()
{
}

size_t
XdnsQuery::GetTcpStartOffset() const
{
    /* The total data size should be saved in the first 2 bytes for
       TCP to send, but it is useless for UDP. So the start offset of
       TCP is 0 and UDP is 2.
    */
    return 0;
}

size_t
XdnsQuery::GetUdpStartOffset() const
{
    return 2;
}

XdnsQueryType
XdnsQuery::GetType() const
{
    return m_type;
}

void
XdnsQuery::NotifyListener(long queryId,
                          XdnsError error,
                          const vector<XdnsHostEntry*>* hostEntries)
{
    if (m_listener != NULL)
    {
        m_listener->GetHostCallback(queryId, error, hostEntries);
    }
}

